package com.atguigu.algorithm.sort;

import java.util.Arrays;

/**
 * 选择排序
 *
 * @author xr-8
 * @date 2022-09-10
 * @time 16:23
 */
public class SelectSort {

    public static void main(String[] args) {
        int arr[] = {5, 0, 7, 4, 10, 1};
//        int arr[] = {1, 2, 3, 4, 5, 6};
//        int arr[] = {2, 1, 3, 4, 5, 6};
        sort(arr);
    }

    public static void sort(int[] arr) {
        int temp;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = i + 1; j <= arr.length - 1; j++) {
                if (arr[i] > arr[j]) {
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }

}
